package com.by.controller;


import com.by.bean.CPXJ;
import com.by.bean.SWXJ;
import com.by.bean.TGXJ;
import com.by.common.bean.ResultBean;
import com.by.common.controller.BaseController;
import com.by.service.QuoteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "报价管理")
@RestController
@RequestMapping("/api/quote")
public class QuoteController extends BaseController {
    private final QuoteService<CPXJ> cpxjQuoteService;
    private final QuoteService<SWXJ> swxjQuoteService;
    private final QuoteService<TGXJ> tgxjQuoteService;

    @Autowired
    public QuoteController(QuoteService<CPXJ> cpxjQuoteService, QuoteService<SWXJ> swxjQuoteService, QuoteService<TGXJ> tgxjQuoteService) {
        this.cpxjQuoteService = cpxjQuoteService;
        this.swxjQuoteService = swxjQuoteService;
        this.tgxjQuoteService = tgxjQuoteService;
    }

    @ApiOperation("产品报价")
    @PostMapping("/cp")
    public ResultBean saveCPXJ(@RequestBody CPXJ cpxj, @RequestParam int id){
        int rs = cpxjQuoteService.save(cpxj, "CPXJ", id);
        return saveResult(rs);
    }

    @ApiOperation("筛网报价")
    @PostMapping("/sw")
    public ResultBean saveSWXJ(@RequestBody SWXJ swxj,@RequestParam int id){
        int rs = swxjQuoteService.save(swxj, "SWXJ", id);
        return saveResult(rs);
    }

    @ApiOperation("托辊报价")
    @PostMapping("/tg")
    public ResultBean saveTGXJ(@RequestBody TGXJ tgxj,@RequestParam int id){
        int rs = tgxjQuoteService.save(tgxj, "TGXJ", id);
        return saveResult(rs);
    }
}
